package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;

public class BankService {

	private final static String savingAccount = "Saving account: ";
	private final static String checkingAccount = " Checking account: ";

	public void addClient(Bank bank, Client client) {
		for (int i = 0; i < bank.clients.length; i++) {
			if (bank.clients[i] == null) {
				bank.clients[i] = client;
				break;
			}
		}
	}

	public void modifyBank(Client client, double amount, boolean meth) {
		if (meth == true) {
			client.accountS.deposit(amount);
		} else {
			client.accountS.withdraw(amount);
		}
	}

	public void printBalance(Bank bank) {
		for (Client client : bank.clients) {
			if (client == null) {
				break;
			}
			System.out.println(client.accountS.getBalance());
		}
	}

	public void printMaximumAmountToWidthdraw(Client client) {
		System.out.print(savingAccount
				+ client.accountS.maximumAmountToWithdraw());
		System.out.println(checkingAccount
				+ client.accountC.maximumAmountToWithdraw());
	}

}
